import Ember from 'ember';

export default Ember.Controller.extend({
  constants: Constants,
  queryCondition:'',
  mainController: Ember.inject.controller('business.mainpage'),
  actions:{
    toDetailPage(){
        this.get("mainController").switchMainPage('scheduled',{editMode:"add",id:''});
    },
    toDetail(flow){
      console.log(flow.get('status.typecode'));
      let status = flow.get('status.typecode');
      if(status=='consultStatus3'){
        this.get("mainController").switchMainPage('scheduled',{editMode:"edit",id:flow.get('id')});
      }
      if(status=='consultStatus4'){
        this.get("mainController").switchMainPage('try',{editMode:"edit",id:flow.get('id')});
      }
      if(status=='consultStatus5'){
        this.get("mainController").switchMainPage('checkin',{editMode:"edit",id:flow.get('id')});
      }
    },
    toEdit(flow){
      let status = flow.get('status.typecode');
      if(status=='consultStatus3'){
        this.get("mainController").switchMainPage('try-customer',{editMode:"edit",id:flow.get('id')});
      }
      if(status=='consultStatus4'){
        this.get("mainController").switchMainPage('checkin-customer',{editMode:"edit",id:flow.get('id')});
      }
      console.log('haha');
    },
    processSearch(id){
      let name = '#' + id;
      if($(name).prop("className").indexOf('active')>0){
        $(name).removeClass('active');
        App.lookup("route:business.mainpage.business-customer").doQuery();
      }else{
        $.find('.processLi').forEach(function(target){
          $(target).removeClass('active');
        });
        $(name).addClass('active');
        App.lookup("route:business.mainpage.business-customer").doQuery(id);
      }
    },
    changeBeginDateAction(date) {
        //var stamp = this.get("dateService").getLastSecondStampOfDay(date);
        //this.set("warningModel.callTime", stamp);
        //var stamp=this.get("dateService").dateFormat(date,"yyyy-MM-dd");
        this.set("beginDate",date);
    },
    changeEndDateAction(date) {
        //var stamp=this.get("dateService").dateFormat(date,"yyyy-MM-dd");
        console.log("is true",typeof date);
        this.set("endDate",date);
    },
    dpShowAction(e){

    },
  }
});
